layui.use(['form','layer','table'],function(){
    var form = layui.form
        layer = parent.layer === undefined ? layui.layer : top.layer,
				table=layui.table,
        $ = layui.jquery;
				
		const tableName=new Vue({
			el: '#tableNameList',
			data:{
				all_data:null,
				tableIns:null
			},
			methods:{
				getAllTableNames:function(){
					this.$http.post(global_url+'/admin/ranking/table/all')
						.then(
						response=>{
							this.all_data=response.body.datas
							this.tablefill()
						},					
						response=>{
						
						})
				},
				updataTableName:function(data){
					this.$http.post(global_url+'/admin/ranking/table/updata',data)
						.then(
						response=>{
								layer.msg('更新成功!')
								this.getAllTableNames()
						},					
						response=>{
						
						})
				},
				tablefill:function(){
					this.tableIns = table.render({
						elem: '#tableNameList',
						cellMinWidth : 95,
						page : true,
						height : "full-125",
						id : "tableNameListTable",
						cols : [[
							{field: 'tId', title: '表ID', width:60, align:"center"},
							{field: 'tableName', title: '表名称', align:"center"},
							{field: 'tableAsName', title: '表别名', align:"center", edit: 'text'},
							
							{title: '操作',  templet:'#tableNameListBar',fixed:"right",align:"center"}
							
						]],data:this.all_data
					});
					
				}
				
			}})
				
		tableName.getAllTableNames()
		
		
		//列表操作
		table.on('tool(tableNameList)', function(obj){
			var layEvent = obj.event,
				data = obj.data;
			if(layEvent === 'edit'){ //编辑
					tableName.updataTableName({"tId":data.tId,"tableAsName":data.tableAsName});
			}
		});
})